You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR cleans up some utility functions in the network code, mainly by refactoring them from if/else chains to switch statements. No change should have a functional difference.
See commits for cleaner (per function) diffs.
Caball009
added
Minor
Severity: Minor < Major < Critical < Blocker
Network
Anything related to network, servers
Refactor
Edits the code with insignificant behavior changes, is never user facing
labels
May 17, 2026
This PR refactors four network utility functions in NetworkUtil.cpp from verbose if/else chains to switch statements, adds const correctness to two function signatures, and introduces a CASE_LABEL helper macro in GetNetCommandTypeAsString to reduce boilerplate.
DoesCommandRequireACommandID and IsCommandSynchronized are converted to switch statements with no change to the set of matching enum values.
CommandRequiresAck is simplified to delegate directly to DoesCommandRequireACommandID, which is correct since both functions historically matched on the identical set of command types (the duplicate NETCOMMANDTYPE_DISCONNECTPLAYER entry in the old if-chain was a copy-paste artifact with no behavioral effect).
GetNetCommandTypeAsString now handles previously missing values (NETCOMMANDTYPE_UNKNOWN, NETCOMMANDTYPE_DISCONNECTSTART, NETCOMMANDTYPE_DISCONNECTEND) and restores the DEBUG_CRASH guard for truly unrecognized types (addressing the feedback from the prior review thread).
Confidence Score: 5/5
Safe to merge — all refactored switch statements cover the same enum values as the original if/else chains, and the addressed feedback from prior threads is correctly incorporated.
Each refactored function was verified to cover the same command types as the original. The CommandRequiresAck delegation to DoesCommandRequireACommandID is correct since the two functions had identical (modulo a copy-paste duplicate) type lists. The GetNetCommandTypeAsString function now properly handles NETCOMMANDTYPE_UNKNOWN and restores the DEBUG_CRASH guard for future unrecognized types. The const corrections in the header are straightforward and non-breaking.
No files require special attention.
Important Files Changed
Filename
Overview
Core/GameEngine/Include/GameNetwork/networkutil.h
Added const correctness to CommandRequiresAck and CommandRequiresDirectSend parameter declarations — minimal, correct change.
Refactored four functions from if/else chains to switch statements; CommandRequiresAck now delegates to DoesCommandRequireACommandID (lists were semantically identical); GetNetCommandTypeAsString adds CASE_LABEL macro, covers previously missing enum values (DISCONNECTSTART, DISCONNECTEND, UNKNOWN), and restores DEBUG_CRASH on unhandled types.
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[NetCommandMsg] -->|getNetCommandType| B{NetCommandType}
B --> C[CommandRequiresAck]
B --> D[CommandRequiresDirectSend]
B --> E[DoesCommandRequireACommandID]
B --> F[IsCommandSynchronized]
B --> G[GetNetCommandTypeAsString]
C -->|delegates to| E
E -->|FRAMEINFO, GAMECOMMAND, PLAYERLEAVE
RUNAHEADMETRICS, RUNAHEAD, DESTROYPLAYER
CHAT, LOADCOMPLETE, TIMEOUTSTART, WRAPPER
FILE, FILEANNOUNCE, FILEPROGRESS
FRAMERESENDREQUEST, DISCONNECTPLAYER
DISCONNECTVOTE, DISCONNECTFRAME
DISCONNECTSCREENOFF| E1[TRUE]
E -->|default| E2[FALSE]
D -->|LOADCOMPLETE, TIMEOUTSTART, FILE
FILEANNOUNCE, FILEPROGRESS
FRAMERESENDREQUEST, DISCONNECTPLAYER
DISCONNECTVOTE, DISCONNECTFRAME
DISCONNECTSCREENOFF| D1[TRUE]
D -->|default| D2[FALSE]
F -->|FRAMEINFO, GAMECOMMAND
PLAYERLEAVE, RUNAHEAD
DESTROYPLAYER| F1[TRUE]
F -->|default| F2[FALSE]
G -->|known type| G1[string literal via CASE_LABEL macro]
G -->|unknown type| G2[DEBUG_CRASH + return NETCOMMANDTYPE_INVALID]
Rebased to include the fix for the CI Replay checker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MinorSeverity: Minor < Major < Critical < BlockerNetworkAnything related to network, serversRefactorEdits the code with insignificant behavior changes, is never user facing
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR cleans up some utility functions in the network code, mainly by refactoring them from if/else chains to switch statements. No change should have a functional difference.
See commits for cleaner (per function) diffs.